<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>禾米租房 -发布房屋信息</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="js/jquery-1.8.0.js"></script>
<script type="text/javascript">

function get() {
	 
	 var xmlhttp;
	 if (window.XMLHttpRequest)
	   {// code for IE7+, Firefox, Chrome, Opera, Safari
	   xmlhttp=new XMLHttpRequest();
	   }
	 else
	   {// code for IE6, IE5
	   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	   }

	 xmlhttp.open("get","street?id="+document.getElementById("district_id").value,true);
	 xmlhttp.send();
	 
	 xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	         var jsonArray=eval("("+xmlhttp.responseText+")");
	         var select =    $("#street_id");
	         select.html("");  //清空选项
	         
	         for( var index in jsonArray){
	        	 var jsonObject=jsonArray[index];
	        	 select.append($("<option value='"+jsonObject.id+"'>"+jsonObject.name+"</option>"));
	         }
	    }
	  }
	}
	
  window.onload=get;

</script>
</head>
<body>
<div id="header" class="wrap">
	<div id="logo"><img src="images/logo.gif" /></div>
</div>
<div id="regLogin" class="wrap">
	<div class="dialog">
		<dl class="clearfix">
			<dt>新房屋信息发布</dt>
			<dd class="past">填写房屋信息</dd>

		</dl>
		<div class="box">
			<form action="user/add" method="post">
				<div class="infos">
					<table class="field">
						<tr>
							<td class="field">标　　题：</td>
							<td>
							<input type="text" id="title" name="title" required="required"/>
							</td>
						</tr>
						<tr>
							<td class="field">户　　型：</td>
							<td><select  class="text" name="type_id">
								<c:forEach var="type" items="${requestScope.typeList}">
								<option value="${type.id }">${type.name }</option>
								</c:forEach>
							</select>
							</td>
						</tr>
						<tr>
							<td class="field">面　　积：</td>
							<td><input type="number" id="floorage" name="floorage" required="required"/></td>
						</tr>
						<tr>
							<td class="field">价　　格：</td>
							<td>
							<input type="number" id="price" name="price" required="required"/>
							</td>
						</tr>
                        <tr>
							<td class="field">位　　置：</td>
							<td>
							区：<select  class="text" id="district_id" name="district_id" required="required" onchange="get()">
							<c:forEach var="district" items="${requestScope.districtList}">
								<option value="${district.id }">${district.name }</option>
								</c:forEach>
							</select>
                            	街：<select  class="text" id="street_id" name="street_id" required="required">
                            	</select>
                            </td>
						</tr>
                        <tr>
							<td class="field">联系方式：</td>
							<td>
							<input type="number"  id="contact" name="contact" required="required"/>
							</td>
						</tr>
                        <tr>
							<td class="field">详细信息：</td>
							<td><textarea name="description" required="required"></textarea></td>
						</tr>
					</table>
					<div class="buttons">
					<input type="submit" value="立即发布"/>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<div id="footer" class="wrap">
	<dl>
    	<dt>禾米租房 &copy; 2010 禾米教育 浙ICP证1000001号</dt>
        <dd>关于我们 · 联系方式 · 意见反馈 · 帮助中心</dd>
    </dl>
</div>
</body>
</html>